/*
 * $Id$
 */

package corejs.parser;

import corejs.JsTokenType;
import corejs.Token;
import corejs.expr.ConditionalExpr;
import corejs.expr.Expression;

/**
 *
 * @author pengyu
 */
public class ConditionalOperatorParser implements InfixParser {

   @Override
   public Expression expr(final PrattParser parser, final Expression left, 
                          final Token currentToken) {
      final Expression then = parser.expr();
      parser.nextToken(JsTokenType.COLON);
      return new ConditionalExpr(left, then, parser.expr());
   }

   @Override
   public int getPrecedence() { return Precedence.CONDITIONAL; }
   
}
